﻿namespace Teach1.Gui.Models
{
    public static class RandomExtensions
    {
        public static double NextGaussian(this Random random, double mean, double stdDev)
        {
            // Using Box-Muller transform
            double u1 = 1.0 - random.NextDouble(); // Uniform(0,1] random doubles
            double u2 = 1.0 - random.NextDouble();
            double randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) *
                                   Math.Sin(2.0 * Math.PI * u2); // Random normal(0,1)
            return mean + stdDev * randStdNormal; // Random normal(mean,stdDev^2)
        }
    }

    
}
